package com.duesoft.myandroid.fragments;

import java.util.Locale;

import android.app.Activity;
import android.app.Fragment;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;

import com.duesoft.myandroid.R;


public class ArticleFragment extends Fragment {

	public static final String ARG_POSITION = "com.duesoft.myandroid.ARGUMENT_POSITION";
	
	private OnArticleSelectedListener mCallback;
	
	public interface OnArticleSelectedListener {
		public void onArticleSelected(int position);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {				
		return inflater.inflate(R.layout.article_view, container, false);
	}
	
	/* (non-Javadoc)
	 * @see android.app.Fragment#onAttach(android.app.Activity)
	 */
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		
		// This makes sure that the container activity has implemented
        // the callback interface. If not, it throws an exception
		try {
			mCallback = (OnArticleSelectedListener)activity;			
			//mCallback.onArticleSelected(position);
			
		} catch (Exception e) {
			// TODO: handle exception
			throw new ClassCastException(activity.toString()
					+ " must implement OnArticleSelectedListener");
		}
	}

	public void updateArticleView(int position) {
		String positionText = new Integer(position).toString();
		
		//FrameLayout frameLayout = (FrameLayout)getActivity().findViewById(R.id.fragment_container);		
		//EditText editText = (EditText)frameLayout.findViewById(R.id.editTextPicture);
		
		EditText editText = (EditText)getActivity().findViewById(R.id.editTextArticle);
		
		editText.setText(positionText);
	}	
}











